const express = require('express')

const router = require('./05.apiRouter')

const app = express()

// 解析请求体数据
app.use(express.json())
app.use(express.urlencoded({ extended: false }))

// 一定要在路由之前配置cors中间件，解决接口跨域问题
const cors = require('cors')
app.use(cors())

app.use('/api', router)

app.listen(3030, () => {
    console.log('服务器已启动 http://localhost:3030')
})